#
# Makefile for the FREAX-kernel.
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (ie not a .c file).
#

AR	=gar
AS	=as --32
LD	=ld -melf_i386 
LDFLAGS	=-s -x 
CC	=gcc -m32
CFLAGS	=-w -O -fstrength-reduce -fomit-frame-pointer \
	-finline-functions -fno-stack-protector \
	-nostdinc -D__LIBRARY__ -Iinclude
CPP     =gcc -E -nostdinc -Iinclude
.c.s:
	$(CC) $(CFLAGS) \
	-S -o $*.s $<
.s.o:
	$(AS) -c -o $*.o $<
.c.o:
	$(CC) $(CFLAGS) \
	-c -o $*.o $<

LIBS  = vsprintf.o write.o errno.o printf.o
lib.o: 	$(LIBS) 
	$(LD) $(LDFLAGS) -r -o lib.o $(LIBS)

clean:
	rm -f core *.o *.a tmp_make
	for i in *.c;do rm -f `basename $$i .c`.s;done

dep:
	sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
	(for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
		$(CPP) -M $$i;done) >> tmp_make
	cp tmp_make Makefile

### Dependencies:
errno.s errno.o: errno.c
vsprintf.s vsprintf.o: vsprintf.c include/stdarg.h include/string.h
write.s write.o: write.c include/unistd.h include/sys/stat.h include/sys/types.h \
 include/sys/times.h include/sys/utsname.h include/utime.h
